

<include file="public@header" />
</head>
<body>
<div class="wrap js-check-wrap">
    <ul class="nav nav-tabs">
        <li class="active"><a>兑换记录</a></li>

    </ul>

    <form class="well form-inline margin-top-20" method="get" >

        用户名:
        <input type="text" class="form-control" id="uanem" style="width: 120px;"  placeholder="请输入用户名">

        券名称:
        <input type="text" class="form-control" id="tname" style="width: 120px;"  placeholder="请输入用户名">
        <!--0=未使用,1=已使用,2=已赠送,3=已过期-->
        状态:
        <select class="form-control" name="category" id="status" style="width: 140px;">
            <option value='-1'>全部</option>
            <option value='0'>未使用</option>
            <option value='1'>已使用</option>
            <option value='3'>已过期</option>
        </select> &nbsp;&nbsp;
        <!--1=赠送,2=后台,0=兑换-->

        <input type="button" id="selectval" class="btn btn-primary" value="搜索" />
        <a class="btn btn-danger" href="{:url('meallogs/index')}">清空</a>
    </form>

    <table class="table table-hover table-bordered">

        <table class="layui-hide" id="test" lay-filter="test"></table>

        <script type="text/html" id="toolbarDemo">
            <div class="layui-btn-container">
                <button class="layui-btn layui-btn-sm " id="allscore"></button>
            </div>
        </script>
        <script type="text/html" id="barDemo">

            {{#  if(d.status == 0){ }}
            <a class="layui-btn layui-btn-xs " lay-event="hexiao">核销</a>
            {{#  } }}
            {{#  if(d.status != 0){ }}
            <a class="layui-btn layui-btn-xs layui-btn-danger">已核销</a>
            {{#  } }}

        </script>

        <script type="text/html" id="titleTpl">
            {{#  if(d.status == 0){ }}未使用 {{#  } }}
            {{#  if(d.status == 1){ }} 未使用{{#  } }}
            {{#  if(d.status == 3){ }} 已过期{{#  } }}
        </script>
        <!--1=赠送,2=后台,0=兑换',-->
        <script type="text/html" id="titleTpl1">
            {{#  if(d.get == 0){ }}用户兑换 {{#  } }}
            {{#  if(d.get == 1){ }} 用户赠送{{#  } }}
            {{#  if(d.get == 2){ }} 后台赠送{{#  } }}
        </script>

        <script>



            layui.use('table', function(){
                var table = layui.table;


                var tableIns =table.render({
                    elem: '#test' ,
                    url:'index',
                    method: 'post',
                    toolbar: '#toolbarDemo',
                    title: '用户数据表',
                    totalRow: true ,
                    cols: [[

                        {field:'id', title:'ID', width:80, fixed: 'left', totalRowText: '合计'}
                        ,{field:'name', title:'餐券'}
                        ,{field:'user_nickname', title:'用户'}
                        ,{field:'', title:'状态', templet: '#titleTpl'}
                        ,{field:'score', title:'积分', totalRow: true,sort: true}

                        ,{field:'endtime', title:'到期'}
                        ,{fixed: 'right', title:'操作', toolbar: '#barDemo'}
                    ]]
                    ,page: true,
                    done: function(res, curr, count){

                        console.log(res);

                        $("#allscore").html('合计使用积分:'+res.msg)
                    }
                });


                $("#selectval").click(function (){

                    var uname=$("#uname").val();
                    var tname=$("#tname").val();
                    var status=$("#status").val();
                    var get=$("#get").val();


                    tableIns.reload({
                        where: { status: status,uname:uname,tname:tname,gets:get} ,
                        page: { curr: 1  }
                    });

                })


            });
        </script>


    </table>

</div>
<script src="__STATIC__/js/admin.js"></script>
</body>
</html>